import 'package:flutter/material.dart';

/// @date 2020/08/13  16:56
/// @author 程志强
/// @des

class MySlideTransition extends AnimatedWidget {
  MySlideTransition(
      {@required Animation<Offset> position,
      this.transformHitTests = true,
      this.child})
      : assert(position != null),
        super(listenable: position);

  Animation<Offset> get position => listenable;

  final bool transformHitTests;
  final Widget child;

  @override
  Widget build(BuildContext context) {
    Offset offset = position.value;
    if (position.status == AnimationStatus.reverse) {
      offset = new Offset(-offset.dx, offset.dy);
    }
    return FractionalTranslation(
      translation: offset,
      transformHitTests: transformHitTests,
      child: child,
    );
  }
}
